package com.taplinker.client.acount.rpc;

import android.content.Context;
import android.util.Log;

import com.taplinker.client.AppConfigContext;
import com.taplinker.client.AppConfigFactory;
import com.taplinker.core.rpc.Result;
import com.taplinker.core.rpc.command.SimpleBaseCommand;
import com.taplinker.core.rpc.http.HttpTemplate;
/**
 * 更新用户密码
 * @author djbian
 *
 */
public class UpdateUserPasswordCommad extends SimpleBaseCommand {
	private static final String TAG = "UpdateUserPasswordCommad";
	private String password = AppConfigFactory.getInstance().getUserInfo().getUserPassword();
	
	public UpdateUserPasswordCommad() {
	}
	
	public UpdateUserPasswordCommad(String password, Context context) {
		super(context);
		this.password = password;
	}
	
	
	@Override
	public Result go() {
		return new HttpTemplate().exchange(AppConfigContext.TAPLINKER_WEB
				+ "/services/userprofile/v1/user/password/" + AppConfigFactory.getInstance().getUserInfo().getUserid());
	}

	@Override
	public void yes(Result result) {
		try {
			AppConfigFactory.getInstance().getUserInfo().setUserPassword(password);
		}catch(Exception e){
			Log.d(TAG, e.getMessage());
		}
	}
}